import { ColumnsRenderFun } from '@/common/ManageUilt';
import { tooltipLength } from '@/utils';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { Tooltip } from 'antd';
import pageStyles from '@/common/pageLayout.less';

/**
 * 供应商统计表格
 * */
export const supplierTableColumns = (onClickSupplierName): Record<string, any>[] => {
  return [
    {
      title: (
        <span>
          供应商名称
          <a style={{ margin: '0 3px' }}>
            <Tooltip title="点击供应商名称，跳转采购实施，获取供应商对应的实施数据">
              <QuestionCircleOutlined />
            </Tooltip>
          </a>
        </span>
      ),
      dataIndex: 'fullName',
      key: 'fullName',
      fixed: 'left',
      width: 300,
      unDrag: true,
      visible: true,
      // sorter: (a: any, b: any) => (a?.fullName > b?.fullName ? 1 : -1),
      render: (text: string | null, record: Record<string, any>) => {
        return (
          <>
            <Tooltip title={tooltipLength(text, 100)}>
              <span className={pageStyles['over-flow-hidden']} onClick={() => onClickSupplierName(record)}>
                <a>{text}</a>
              </span>
            </Tooltip>
          </>
        );
      },
    },
    {
      title: '金额总数',
      dataIndex: 'expectAllSum',
      key: 'expectAllSum',
      fixed: 'left',
      width: 300,
      unDrag: true,
      visible: true,
      sorter: (a: any, b: any) => (a?.expectAllSum > b?.expectAllSum ? 1 : -1),
      render: (text: string | null, record: Record<string, any>) => ColumnsRenderFun({ text }),
    },
    {
      title: '推荐中标数',
      dataIndex: 'totalNum',
      key: 'totalNum',
      fixed: 'left',
      width: 300,
      unDrag: true,
      visible: true,
      sorter: (a: any, b: any) => (a?.totalNum > b?.totalNum ? 1 : -1),
      render: (text: string | null, record: Record<string, any>) => ColumnsRenderFun({ text }),
    },
  ];
};
